package zcc.fetch;

import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import zcc.bean.Hzaqi;
import zcc.bean.Zjaqi;
import zcc.mapper.HzaqiMapper;
import zcc.mapper.ZjaqiMapper;
import flex.messaging.io.ArrayCollection;
import flex.messaging.io.amf.client.exceptions.*;
import flex.messaging.io.amf.ActionMessage;
import flex.messaging.io.amf.AmfMessageSerializer;
import flex.messaging.io.amf.ASObject;
import flex.messaging.io.amf.MessageBody;
import flex.messaging.io.amf.client.*;

import java.util.*;

import javax.servlet.http.HttpServlet;

public class AqiServlet extends HttpServlet{
	private Logger logger = LoggerFactory.getLogger(AqiServlet.class);
    private java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public void init()
	{
		Timer timer = new Timer();
		timer.scheduleAtFixedRate(new TimerTask(){
			   public void run()
			   {  
//			       System.out.println("execute task!" + this.scheduledExecutionTime());
				   long second1=System.currentTimeMillis();
			       insertHz();
			       insertZj();
			       long second2=System.currentTimeMillis();
			       System.out.print("本次抓取耗时：");
			       System.out.print((second2-second1)/1000f);
			       System.out.println("秒");
			   }  
			},0,30*60*1000);
	}
	
	@SuppressWarnings("unused")
	public void insertHz(){
		logger.info("Getting PM2.5 of hangzhou");
	 try {
	        AMFConnection connection = new AMFConnection();
	        //connection.connect("http://115.236.164.226:8099/messagebroker/amf");//zhejiang
	        connection.connect("http://218.108.6.124:8080/messagebroker/amf");//hangzhou
	        //设置代理
	        if(Proxy.p!=0){
		        Properties systemProperties = System.getProperties();
		        systemProperties.setProperty("http.proxyHost",Proxy.strProxy);
		        systemProperties.setProperty("http.proxyPort",Proxy.strPort);
	        }
	        ArrayCollection result = (ArrayCollection) connection.call("GisCommonDataUtil.getRealTimeAQIDataCollection");
	        int size = result.size();
	        int index = 1;
	        ApplicationContext aContext = new ClassPathXmlApplicationContext("./applicationContext.xml");
    	    HzaqiMapper hzaqiMapper = aContext.getBean(HzaqiMapper.class);
	        for (int i=0;i<size;i++) {
	            ASObject obj = (ASObject) result.get(i);
//	            System.out.println(obj);
//==============将obj存入数据库======================================================================================
	    	    Hzaqi hzaqi = new Hzaqi();
	    	    //获取sitename和cityname
	    	    ASObject site=(ASObject)obj.get("site");
	    	    if(site!=null){
		    	    hzaqi.setSitename((String)site.get("name"));
		    	    ASObject city=(ASObject)site.get("city");
		    	    hzaqi.setCityname((String)city.get("name"));
		    	    if(site.get("longitude")!=null)		hzaqi.setLongitude((String)site.get("longitude"));
		    	    if(site.get("latitude")!=null)		hzaqi.setLatitude((String)site.get("latitude"));
	    	    }
	    	    //获取standard
	    	    ASObject standard=(ASObject)obj.get("standard");
	    	    if(standard!=null){
		    	    if(standard.get("level")!=null)		hzaqi.setLevel((String)standard.get("level"));
		    	    if(standard.get("color")!=null)		hzaqi.setColor((String)standard.get("color"));
		    	    if(standard.get("influence")!=null)	hzaqi.setInfluence((String)standard.get("influence"));
		    	    if(standard.get("suggest")!=null)	hzaqi.setSuggest((String)standard.get("suggest"));
		    	    if(standard.get("type")!=null)		hzaqi.setType((String)standard.get("type"));
		    	    if(standard.get("minAPI")!=null)	hzaqi.setMinapi((int)standard.get("minAPI"));
	    	    }
	    	    //aqi值
	    	    if(obj.get("aqi")!=null)
	    	    {
	    	    	int aqi=(int)obj.get("aqi");
	    	    	hzaqi.setAqi(aqi);
	    	    }
	    	    //时间
	    	    hzaqi.setMonitortime((Date)obj.get("monitorTime"));
	    	    //主要污染物
	    	    ArrayList cp = (ArrayList)obj.get("chiefPollutants");
	    	    if(cp!=null){
	    	    	String str = "";
	    	    	for(Object o:cp){
	    	    		ASObject asobj = (ASObject)o;
	    	    		ASObject chiefpollutants = asobj;
	    	    		if(!str.equals(""))
	    	    			str=str+","+(String)chiefpollutants.get("egName");
	    	    		else
	    	    			str=(String)chiefpollutants.get("egName");
	    	    	}
	    	    	if(!str.equals("")){
	    	    		hzaqi.setChiefpollutants(str);
	    	    	}
	    	    }
	    	    //各污染物浓度
	    	    ASObject iaqi = (ASObject)obj.get("iaqiDataMap");
	    	    if(iaqi!=null){
		    	    //pm2.5
		    	    ASObject pm25 = (ASObject)iaqi.get("121");
		    	    if(pm25!=null){	
		    	    	if(pm25.get("publishData")!=null)	hzaqi.setPm25((double)pm25.get("publishData"));
			    	    if(pm25.get("maxEightIAQI")!=null)	hzaqi.setPm25max8iaqi((int)pm25.get("maxEightIAQI"));
			    	    if(pm25.get("avgDayData")!=null)	hzaqi.setPm25avgdaydata((double)pm25.get("avgDayData"));
			    	    if(pm25.get("hourData")!=null)		hzaqi.setPm25hourdata((double)pm25.get("hourData"));
			    	    if(pm25.get("avgEightData")!=null)	hzaqi.setPm25avg8data((double)pm25.get("avgEightData"));
			    	    if(pm25.get("maxOneData")!=null)	hzaqi.setPm25max1data((double)pm25.get("maxOneData"));
			    	    if(pm25.get("avgEightIAQI")!=null)	hzaqi.setPm25avg8iaqi((int)pm25.get("avgEightIAQI"));
			    	    if(pm25.get("avgDayIAQI")!=null)	hzaqi.setPm25avgdayiaqi((int)pm25.get("avgDayIAQI"));
		    	    }
		    	    //o3
		    	    ASObject o3 = (ASObject)iaqi.get("108");
		    	    if(o3!=null){
			    	    if(o3.get("publishData")!=null)		hzaqi.setO3((double)o3.get("publishData"));
			    	    if(o3.get("maxEightIAQI")!=null)	hzaqi.setO3max8iaqi((int)o3.get("maxEightIAQI"));
			    	    if(o3.get("avgDayData")!=null)		hzaqi.setO3avgdaydata((double)o3.get("avgDayData"));
			    	    if(o3.get("hourData")!=null)		hzaqi.setO3hourdata((double)o3.get("hourData"));
			    	    if(o3.get("avgEightData")!=null)	hzaqi.setO3avg8data((double)o3.get("avgEightData"));
			    	    if(o3.get("maxOneData")!=null)		hzaqi.setO3max1data((double)o3.get("maxOneData"));
			    	    if(o3.get("avgEightIAQI")!=null)	hzaqi.setO3avg8iaqi((int)o3.get("avgEightIAQI"));
			    	    if(o3.get("avgDayIAQI")!=null)		hzaqi.setO3avgdayiaqi((int)o3.get("avgDayIAQI"));
		    	    }
		    	    //pm10
		    	    ASObject pm10 = (ASObject)iaqi.get("107");
		    	    if(pm10!=null){
		    	    	if(pm10.get("publishData")!=null)	hzaqi.setPm10((double)pm10.get("publishData"));
			    	    if(pm10.get("maxEightIAQI")!=null)	hzaqi.setPm10max8iaqi((int)pm10.get("maxEightIAQI"));
			    	    if(pm10.get("avgDayData")!=null)	hzaqi.setPm10avgdaydata((double)pm10.get("avgDayData"));
			    	    if(pm10.get("hourData")!=null)		hzaqi.setPm10hourdata((double)pm10.get("hourData"));
			    	    if(pm10.get("avgEightData")!=null)	hzaqi.setPm10avg8data((double)pm10.get("avgEightData"));
			    	    if(pm10.get("maxOneData")!=null)	hzaqi.setPm10max1data((double)pm10.get("maxOneData"));
			    	    if(pm10.get("avgEightIAQI")!=null)	hzaqi.setPm10avg8iaqi((int)pm10.get("avgEightIAQI"));
			    	    if(pm10.get("avgDayIAQI")!=null)	hzaqi.setPm10avgdayiaqi((int)pm10.get("avgDayIAQI"));
		    	    }
		    	    //co
		    	    ASObject co = (ASObject)iaqi.get("106");
		    	    if(co!=null){
			    	    if(co.get("publishData")!=null)		hzaqi.setCo((double)co.get("publishData"));
			    	    if(co.get("maxEightIAQI")!=null)	hzaqi.setComax8iaqi((int)co.get("maxEightIAQI"));
			    	    if(co.get("avgDayData")!=null)		hzaqi.setCoavgdaydata((double)co.get("avgDayData"));
			    	    if(co.get("hourData")!=null)		hzaqi.setCohourdata((double)co.get("hourData"));
			    	    if(co.get("avgEightData")!=null)	hzaqi.setCoavg8data((double)co.get("avgEightData"));
			    	    if(co.get("maxOneData")!=null)		hzaqi.setComax1data((double)co.get("maxOneData"));
			    	    if(co.get("avgEightIAQI")!=null)	hzaqi.setCoavg8iaqi((int)co.get("avgEightIAQI"));
			    	    if(co.get("avgDayIAQI")!=null)		hzaqi.setCoavgdayiaqi((int)co.get("avgDayIAQI"));
		    	    }
		    	    //so2
		    	    ASObject so2 = (ASObject)iaqi.get("101");
		    	    if(so2!=null){
			    	    if(so2.get("publishData")!=null)	hzaqi.setSo2((double)so2.get("publishData"));
			    	    if(so2.get("maxEightIAQI")!=null)	hzaqi.setSo2max8iaqi((int)so2.get("maxEightIAQI"));
			    	    if(so2.get("avgDayData")!=null)		hzaqi.setSo2avgdaydata((double)so2.get("avgDayData"));
			    	    if(so2.get("hourData")!=null)		hzaqi.setSo2hourdata((double)so2.get("hourData"));
			    	    if(so2.get("avgEightData")!=null)	hzaqi.setSo2avg8data((double)so2.get("avgEightData"));
			    	    if(so2.get("maxOneData")!=null)		hzaqi.setSo2max1data((double)so2.get("maxOneData"));
			    	    if(so2.get("avgEightIAQI")!=null)	hzaqi.setSo2avg8iaqi((int)so2.get("avgEightIAQI"));
			    	    if(so2.get("avgDayIAQI")!=null)		hzaqi.setSo2avgdayiaqi((int)so2.get("avgDayIAQI"));
		    	    }
		    	    //no2
		    	    ASObject no2 = (ASObject)iaqi.get("141");
		    	    if(no2!=null){					
			    	    if(no2.get("publishData")!=null)	hzaqi.setNo2((double)no2.get("publishData"));
			    	    if(no2.get("maxEightIAQI")!=null)	hzaqi.setNo2max8iaqi((int)no2.get("maxEightIAQI"));
			    	    if(no2.get("avgDayData")!=null)		hzaqi.setNo2avgdaydata((double)no2.get("avgDayData"));
			    	    if(no2.get("hourData")!=null)		hzaqi.setNo2hourdata((double)no2.get("hourData"));
			    	    if(no2.get("avgEightData")!=null)	hzaqi.setNo2avg8data((double)no2.get("avgEightData"));
			    	    if(no2.get("maxOneData")!=null)		hzaqi.setNo2max1data((double)no2.get("maxOneData"));
			    	    if(no2.get("avgEightIAQI")!=null)	hzaqi.setNo2avg8iaqi((int)no2.get("avgEightIAQI"));
			    	    if(no2.get("avgDayIAQI")!=null)		hzaqi.setNo2avgdayiaqi((int)no2.get("avgDayIAQI"));
		    	    }
	    	    }
//	            int aqi = (int) obj.get("aqi");
//	            Date d = (Date) obj.get("monitorTime");
//	            obj = (ASObject) obj.get("site");
//	            String site = (String) obj.get("name");  
	    	    
	    	    //判断该条数据是否已插入
		    	    int j = hzaqiMapper.getHzaqiBySiteTime(hzaqi.getSitename(), hzaqi.getCityname(), hzaqi.getMonitortime());
		    	    if(j!=0){
		    	    	System.out.println(index);index=index+1;
		    	    	logger.info("该数据已记录过："+hzaqi.getSitename()+"    "+format1.format(hzaqi.getMonitortime()));
		    	    }
		    	    else{
			    	    hzaqiMapper.insertHzaqi(hzaqi);
			    	    System.out.println(index);index=index+1;
			    	    System.out.println("添加成功："+hzaqi.getSitename()+"    "+format1.format(hzaqi.getMonitortime()));
		    	    }
	        }
	        aContext=null;
	        connection.close();
	    } catch (Exception e) {
	        logger.error("fetch PM2.5 failed:", e);
	    }
	}
	
	@SuppressWarnings("unused")
	public void insertZj(){
		System.out.println("################################################################################################################################");
		logger.info("Getting PM2.5 of zhejiang");
	 try {
	        AMFConnection connection = new AMFConnection();
	        connection.connect("http://115.236.164.226:8099/messagebroker/amf");//zhejiang
//	        connection.connect("http://218.108.6.124:8080/messagebroker/amf");//hangzhou
	        //设置代理
	        if(Proxy.p!=0){
		        Properties systemProperties = System.getProperties(); 
		        systemProperties.setProperty("http.proxyHost",Proxy.strProxy); 
		        systemProperties.setProperty("http.proxyPort",Proxy.strPort);
	        }
	        ArrayCollection result = (ArrayCollection) connection.call("GisCommonDataUtil.getRealTimeAQIDataCollection");
	        int size = result.size();
	        int index = 1;
    	 	ApplicationContext aContext = new ClassPathXmlApplicationContext("./applicationContext.xml");  
    	    ZjaqiMapper zjaqiMapper = aContext.getBean(ZjaqiMapper.class);
	        for (int i=0;i<size;i++) {
	            ASObject obj = (ASObject) result.get(i);
//	            System.out.println(obj);
//==============将obj存入数据库======================================================================================
	    	    Zjaqi zjaqi = new Zjaqi();
	    	    //获取sitename和cityname
	    	    ASObject site=(ASObject)obj.get("site");
	    	    if(site!=null){
		    	    zjaqi.setSitename((String)site.get("name"));
		    	    ASObject city=(ASObject)site.get("city");
		    	    zjaqi.setCityname((String)city.get("name"));
		    	    if(site.get("longitude")!=null)		zjaqi.setLongitude((String)site.get("longitude"));
		    	    if(site.get("latitude")!=null)		zjaqi.setLatitude((String)site.get("latitude"));
	    	    }
	    	    //获取standard
	    	    ASObject standard=(ASObject)obj.get("standard");
	    	    if(standard!=null){
		    	    if(standard.get("level")!=null)		zjaqi.setLevel((String)standard.get("level"));
		    	    if(standard.get("color")!=null)		zjaqi.setColor((String)standard.get("color"));
		    	    if(standard.get("influence")!=null)	zjaqi.setInfluence((String)standard.get("influence"));
		    	    if(standard.get("suggest")!=null)	zjaqi.setSuggest((String)standard.get("suggest"));
		    	    if(standard.get("type")!=null)		zjaqi.setType((String)standard.get("type"));
		    	    if(standard.get("minAPI")!=null)	zjaqi.setMinapi((int)standard.get("minAPI"));
	    	    }
	    	    //aqi值
	    	    if(obj.get("aqi")!=null)
	    	    {
	    	    	int aqi=(int)obj.get("aqi");
	    	    	zjaqi.setAqi(aqi);
	    	    }
	    	    //时间
	    	    zjaqi.setMonitortime((Date)obj.get("monitorTime"));
	    	    //主要污染物
	    	    ArrayList cp = (ArrayList)obj.get("chiefPollutants");
	    	    if(cp!=null){
	    	    	String str = "";
	    	    	for(Object o:cp){
	    	    		ASObject asobj = (ASObject)o;
	    	    		ASObject chiefpollutants = asobj;
	    	    		if(!str.equals(""))
	    	    			str=str+","+(String)chiefpollutants.get("egName");
	    	    		else
	    	    			str=(String)chiefpollutants.get("egName");
	    	    	}
	    	    	if(!str.equals("")){
	    	    		zjaqi.setChiefpollutants(str);
	    	    	}
	    	    }
	    	    //各污染物浓度
	    	    ASObject iaqi = (ASObject)obj.get("iaqiDataMap");
	    	    if(iaqi!=null){
		    	    //pm2.5
		    	    ASObject pm25 = (ASObject)iaqi.get("121");
		    	    if(pm25!=null){						
			    	    if(pm25.get("publishData")!=null)	zjaqi.setPm25((double)pm25.get("publishData"));
			    	    if(pm25.get("maxEightIAQI")!=null)	zjaqi.setPm25max8iaqi((int)pm25.get("maxEightIAQI"));
			    	    if(pm25.get("avgDayData")!=null)	zjaqi.setPm25avgdaydata((double)pm25.get("avgDayData"));
			    	    if(pm25.get("hourData")!=null)		zjaqi.setPm25hourdata((double)pm25.get("hourData"));
			    	    if(pm25.get("avgEightData")!=null)	zjaqi.setPm25avg8data((double)pm25.get("avgEightData"));
			    	    if(pm25.get("maxOneData")!=null)	zjaqi.setPm25max1data((double)pm25.get("maxOneData"));
			    	    if(pm25.get("avgEightIAQI")!=null)	zjaqi.setPm25avg8iaqi((int)pm25.get("avgEightIAQI"));
			    	    if(pm25.get("avgDayIAQI")!=null)	zjaqi.setPm25avgdayiaqi((int)pm25.get("avgDayIAQI"));
		    	    }
		    	    //o3
		    	    ASObject o3 = (ASObject)iaqi.get("108");
		    	    if(o3!=null){						
			    	    if(o3.get("publishData")!=null)		zjaqi.setO3((double)o3.get("publishData"));
			    	    if(o3.get("maxEightIAQI")!=null)	zjaqi.setO3max8iaqi((int)o3.get("maxEightIAQI"));
			    	    if(o3.get("avgDayData")!=null)		zjaqi.setO3avgdaydata((double)o3.get("avgDayData"));
			    	    if(o3.get("hourData")!=null)		zjaqi.setO3hourdata((double)o3.get("hourData"));
			    	    if(o3.get("avgEightData")!=null)	zjaqi.setO3avg8data((double)o3.get("avgEightData"));
			    	    if(o3.get("maxOneData")!=null)		zjaqi.setO3max1data((double)o3.get("maxOneData"));
			    	    if(o3.get("avgEightIAQI")!=null)	zjaqi.setO3avg8iaqi((int)o3.get("avgEightIAQI"));
			    	    if(o3.get("avgDayIAQI")!=null)		zjaqi.setO3avgdayiaqi((int)o3.get("avgDayIAQI"));
		    	    }
		    	    //pm10
		    	    ASObject pm10 = (ASObject)iaqi.get("107");
		    	    if(pm10!=null){
			    	    if(pm10.get("publishData")!=null)		zjaqi.setPm10((double)pm10.get("publishData"));
			    	    if(pm10.get("maxEightIAQI")!=null)		zjaqi.setPm10max8iaqi((int)pm10.get("maxEightIAQI"));
			    	    if(pm10.get("avgDayData")!=null)		zjaqi.setPm10avgdaydata((double)pm10.get("avgDayData"));
			    	    if(pm10.get("hourData")!=null)			zjaqi.setPm10hourdata((double)pm10.get("hourData"));
			    	    if(pm10.get("avgEightData")!=null)		zjaqi.setPm10avg8data((double)pm10.get("avgEightData"));
			    	    if(pm10.get("maxOneData")!=null)		zjaqi.setPm10max1data((double)pm10.get("maxOneData"));
			    	    if(pm10.get("avgEightIAQI")!=null)		zjaqi.setPm10avg8iaqi((int)pm10.get("avgEightIAQI"));
			    	    if(pm10.get("avgDayIAQI")!=null)		zjaqi.setPm10avgdayiaqi((int)pm10.get("avgDayIAQI"));
		    	    }
		    	    //co
		    	    ASObject co = (ASObject)iaqi.get("106");
		    	    if(co!=null){						
			    	    if(co.get("publishData")!=null)		zjaqi.setCo((double)co.get("publishData"));
			    	    if(co.get("maxEightIAQI")!=null)	zjaqi.setComax8iaqi((int)co.get("maxEightIAQI"));
			    	    if(co.get("avgDayData")!=null)		zjaqi.setCoavgdaydata((double)co.get("avgDayData"));
			    	    if(co.get("hourData")!=null)		zjaqi.setCohourdata((double)co.get("hourData"));
			    	    if(co.get("avgEightData")!=null)	zjaqi.setCoavg8data((double)co.get("avgEightData"));
			    	    if(co.get("maxOneData")!=null)		zjaqi.setComax1data((double)co.get("maxOneData"));
			    	    if(co.get("avgEightIAQI")!=null)	zjaqi.setCoavg8iaqi((int)co.get("avgEightIAQI"));
			    	    if(co.get("avgDayIAQI")!=null)		zjaqi.setCoavgdayiaqi((int)co.get("avgDayIAQI"));
		    	    }
		    	    //so2
		    	    ASObject so2 = (ASObject)iaqi.get("101");
		    	    if(so2!=null){						
			    	    if(so2.get("publishData")!=null)	zjaqi.setSo2((double)so2.get("publishData"));
			    	    if(so2.get("maxEightIAQI")!=null)	zjaqi.setSo2max8iaqi((int)so2.get("maxEightIAQI"));
			    	    if(so2.get("avgDayData")!=null)		zjaqi.setSo2avgdaydata((double)so2.get("avgDayData"));
			    	    if(so2.get("hourData")!=null)		zjaqi.setSo2hourdata((double)so2.get("hourData"));
			    	    if(so2.get("avgEightData")!=null)	zjaqi.setSo2avg8data((double)so2.get("avgEightData"));
			    	    if(so2.get("maxOneData")!=null)		zjaqi.setSo2max1data((double)so2.get("maxOneData"));
			    	    if(so2.get("avgEightIAQI")!=null)	zjaqi.setSo2avg8iaqi((int)so2.get("avgEightIAQI"));
			    	    if(so2.get("avgDayIAQI")!=null)		zjaqi.setSo2avgdayiaqi((int)so2.get("avgDayIAQI"));
		    	    }
		    	    //no2
		    	    ASObject no2 = (ASObject)iaqi.get("141");
		    	    if(no2!=null){						
			    	    if(no2.get("publishData")!=null)	zjaqi.setNo2((double)no2.get("publishData"));
			    	    if(no2.get("maxEightIAQI")!=null)	zjaqi.setNo2max8iaqi((int)no2.get("maxEightIAQI"));
			    	    if(no2.get("avgDayData")!=null)		zjaqi.setNo2avgdaydata((double)no2.get("avgDayData"));
			    	    if(no2.get("hourData")!=null)		zjaqi.setNo2hourdata((double)no2.get("hourData"));
			    	    if(no2.get("avgEightData")!=null)	zjaqi.setNo2avg8data((double)no2.get("avgEightData"));
			    	    if(no2.get("maxOneData")!=null)		zjaqi.setNo2max1data((double)no2.get("maxOneData"));
			    	    if(no2.get("avgEightIAQI")!=null)	zjaqi.setNo2avg8iaqi((int)no2.get("avgEightIAQI"));
			    	    if(no2.get("avgDayIAQI")!=null)		zjaqi.setNo2avgdayiaqi((int)no2.get("avgDayIAQI"));
		    	    }
	    	    }
//	            int aqi = (int) obj.get("aqi");
//	            Date d = (Date) obj.get("monitorTime");
//	            obj = (ASObject) obj.get("site");
//	            String site = (String) obj.get("name");  
	    	    
	    	    //判断该条数据是否已插入
		    	    int j = zjaqiMapper.getZjaqiBySiteTime(zjaqi.getSitename(), zjaqi.getCityname(), zjaqi.getMonitortime());
		    	    if(j!=0){
		    		    System.out.println(index);index=index+1;
		    	    	logger.info("该时段已记录过："+zjaqi.getSitename()+"    "+format1.format(zjaqi.getMonitortime()));
		    	    }
		    	    else{
			    	    zjaqiMapper.insertZjaqi(zjaqi);
			    	    System.out.println(index);index=index+1;
			    	    System.out.println("添加成功："+zjaqi.getSitename()+"    "+format1.format(zjaqi.getMonitortime()));
		    	    }
	        }
	        aContext=null;
	        connection.close();
	    } catch (Exception e) {
	        logger.error("fetch PM2.5 failed:", e);
	    }
	}
}
